#该函数是花园的主函数，似乎由命令方块每秒运行一次
#alreadyexecuted#scoreboard objectives add SeGa_NumPartic dummy
#alreadyexecuted#scoreboard objectives add SeGa_NumMob dummy
#alreadyexecuted#scoreboard objectives add SeGa_StandLastQ dummy

#统计信息
execute store result score playerCount Azr_system if entity @a[tag=azrPlayer]
execute store result score mobCount Azr_system if entity @e[tag=AzrielMob,tag=!AzrielDecMob]
#检测怪物数量 根据玩家人数计算 决定是否停秒
#- 1人        6个以下（含）个敌对怪物不触发停秒，7个怪物以上时有85%的几率停秒，每秒判定一次
#- 2人        6个以下（含）个敌对怪物不触发停秒，7个怪物以上时有83%的几率停秒，每秒判定一次
#- 3人        6个以下（含）个敌对怪物不触发停秒，7个怪物以上时有80%的几率停秒，每秒判定一次
#- 4人        6个以下（含）个敌对怪物不触发停秒，7个怪物以上时有75%的几率停秒，每秒判定一次
#- 5人        8个以下（含）个敌对怪物不触发停秒，9个怪物以上时有75%的几率停秒，每秒判定一次
#- 6人        6个以下（含）个敌对怪物不触发停秒，9个怪物以上时有75%的几率停秒，每秒判定一次
#- 7人以上  9个以下（含）个敌对怪物不触发停秒，10个怪物以上时有50%的几率停秒，每秒判定一次
execute if score playerCount Azr_system matches 1..2 if score mobCount Azr_system matches ..6 run tag @e[tag=sc,limit=1] remove Azr_Halt
execute if score mobCount Azr_system matches 7.. run function skyblock:azr/ingame_azrielsmidgarden_core_sub_countmob1
execute if score playerCount Azr_system matches 3..4 if score mobCount Azr_system matches ..6 run tag @e[tag=sc,limit=1] remove Azr_Halt
execute if score playerCount Azr_system matches 5..6 if score mobCount Azr_system matches ..8 run tag @e[tag=sc,limit=1] remove Azr_Halt
execute if score playerCount Azr_system matches 7.. if score mobCount Azr_system matches ..9 run tag @e[tag=sc,limit=1] remove Azr_Halt
#自动读秒
execute if entity @e[tag=sc,limit=1,tag=!Azr_Halt] run scoreboard players add @e[tag=sc,limit=1] SeGa_StandLast 1
#在部分关卡强制读秒
execute if entity @e[tag=sc,limit=1,tag=Azr_Halt] run function skyblock:azr/force_seconds
#在不同关卡进度调用不同的子主函数
execute if entity @e[tag=!Azr_Halt,tag=sc,limit=1,scores={SeGa_StandLastP=1..9}] run function skyblock:azr/ingame_azrielsmidgarden_core_sub1
execute if entity @e[tag=sc,limit=1,scores={SeGa_StandLastP=11}] run scoreboard players set @e[tag=sc,limit=1] SeGa_StandLast 0
execute if entity @e[tag=!Azr_Halt,tag=sc,limit=1,scores={SeGa_StandLastP=12..13}] run function skyblock:azr/azrielsmidgarden_stage_5
execute if entity @e[tag=sc,limit=1,scores={SeGa_StandLastP=14}] run function skyblock:azr/azrielsmidgarden_stage_event7
execute if entity @e[tag=!Azr_Halt,tag=sc,limit=1,scores={SeGa_StandLastP=15}] run function skyblock:azr/azrielsmidgarden_stage_6
execute if entity @e[tag=sc,limit=1,scores={SeGa_StandLastP=16}] run scoreboard players set @e[tag=sc,limit=1] SeGa_StandLast 0
execute if entity @e[tag=sc,limit=1,scores={SeGa_StandLastP=16..}] run function skyblock:azr/azrielsmidgarden_stage_event2
execute if entity @e[tag=!Azr_Halt,tag=sc,limit=1,scores={SeGa_StandLastP=17},tag=!azrstage7b] run function skyblock:azr/azrielsmidgarden_stage_7
execute if entity @e[tag=!Azr_Halt,tag=sc,limit=1,scores={SeGa_StandLastP=17},tag=azrstage7b] run function skyblock:azr/azrielsmidgarden_stage_7_m
execute if entity @e[tag=!Azr_Halt,tag=sc,limit=1,scores={SeGa_StandLastP=19}] run function skyblock:azr/azrielsmidgarden_stage_8
execute if entity @e[tag=!Azr_Halt,tag=sc,limit=1,scores={SeGa_StandLastP=24..34}] run function skyblock:azr/ingame_azrielsmidgarden_core_sub2
execute if entity @e[tag=sc,limit=1,scores={SeGa_StandLastP=301..399}] run function skyblock:azr/ingame_azrielsmidgarden_core_sub4
#消除蜘蛛占位
execute as @e[tag=AzrielMob,tag=!AzrielDecMob,tag=!AzrielBossA,tag=!AzrielBossB] at @s run scoreboard players add @s SeGa_BecomeWild 1
execute as @e[tag=AzrielMob,tag=!AzrielDecMob,tag=!AzrielBossA,tag=!AzrielBossB,type=spider] at @s run scoreboard players add @s SeGa_BecomeWild 9
execute as @e[tag=AzrielMob,tag=!AzrielDecMob,tag=!AzrielBossA,tag=!AzrielBossB,type=cave_spider] at @s run scoreboard players add @s SeGa_BecomeWild 9
execute as @e[tag=AzrielMob,tag=!AzrielDecMob,scores={SeGa_BecomeWild=240..}] at @s run tag @s add AzrielDecMob
#探测罗盘
execute as @a[nbt={SelectedItem:{id:"minecraft:compass"}}] at @s unless entity @e[distance=0..20,tag=AzrielBossB] run function skyblock:azr/azrielsmidgarden_effect_compass
execute as @a[nbt={SelectedItem:{id:"minecraft:compass"}}] at @s if entity @e[distance=0..20,tag=AzrielBossB] run function skyblock:azr/azrielsmidgarden_effect_compass_boss3
execute as @a[tag=azrPlayer] at @s if score @s Azr_startCount < Pointer Azr_startCount run kill @s
#重置计时器
scoreboard players set gametick Azr_system 0